<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2014/9/9
  Time: 16:46
  To change this template use File | Settings | File Templates.
--%>
<!doctype html>
<html lang="en">
<!--[if lt IE 7 ]>
<html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>
<html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>
<html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html lang="en"> <!--<![endif]-->
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="/resources/bootstrap/css/bootstrap.min.css">
    <%--<!-- 可选的Bootstrap主题文件（一般不用引入） -->--%>
    <%--<link rel="stylesheet" href="/resources/bootstrap/css/bootstrap-theme.min.css">--%>
    <link rel="stylesheet" href="/resources/public/css/public.css">
    <link rel="stylesheet" href="/resources/dialog/aui-artDialog/css/ui-dialog.css">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="/resources/jquery/jquery-2.1.1.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="/resources/bootstrap/js/bootstrap.min.js"></script>
    <!-- 配置文件 -->
    <script type="text/javascript" src="/resources/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="/resources/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" src="/resources/dialog/aui-artDialog/dist/dialog-min.js"></script>
    <title>留言</title>
</head>
<style>
    .main-container {
        margin: 35px auto auto auto;
        position: relative;
        width: 70%;
    }
    .post{
        padding: 50px;
    }
</style>
<body>
<jsp:include page="../header.jsp"/>
<!-- 加载编辑器的容器 -->
<div class="container main-container">
    <div class="row">
        <div class="col-md-12">
            <c:forEach items="${list}" var="message">
            <div class="post">
                <input type="hidden" name="id" value="${message.id}">
                <p>${message.content}</p>
                <p>来自IP:${message.source_ip} &nbsp; &nbsp; 留言时间：<fmt:parseDate  value="${message.create_time}" pattern="yyyy-MM-dd HH:mm:ss" var="date"/> <fmt:formatDate value="${date}" pattern="yyyy-MM-dd HH:mm:ss"/></p>
                <h5 style="border-bottom:1px solid #EEEEEE;clear: both"/>
            </div>
            </c:forEach>
            <!-- 实例化编辑器 -->
            <form action="/AddMessageBoard" method="post" name="form">
            <script id="editor" type="text/plain" name="content"></script>
            <%--<button onclick="commit()">提交</button>--%>
                <button type="submit" onclick ="return valid();">提交</button>
                <input type="hidden" name="source_ip" id="source_ip">
            </form>
        </div>
    </div>
</div>
<jsp:include page="../footer.jsp"/>
<script type="text/javascript">
    var ue = UE.getEditor('editor');
    $(function() {
        var url = 'http://chaxun.1616.net/s.php?type=ip&output=json&callback=?&_='+Math.random();
        $.getJSON(url, function(data){
            $("#source_ip").val(data.Ip)
       });
    });
    function valid(){
        var d = dialog({
            fixed: true,
            title: '提示',
            content: '请输入留言内容！'
        });
        if(!ue.hasContents()){
            d.showModal();
            setTimeout(function () {
                d.close().remove();
            }, 1000);
            return false;
        }
        return true;
    }
</script>
</body>
</html>
